<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>老人管理-老人信息-新增老人</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="/senior_assets/layertwo-assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="/senior_assets/layertwo-assets/css/style.css" rel="stylesheet">
    <link href="/senior_assets/layertwo-assets/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="/plugins/SweetAlert/sweetalert.css" />
    <script src="/plugins/jQuery/jquery-2.1.1.min.js"></script>
    <script src="/js/fakeloader.min.js"></script>
</head>
<body>
    <div class="container-fluid">
        <div class="om-ctl-mes">
            <div class="title">
                <div class="col-xs-12"><span class="fa fa-list-ul"> 老人管理</span><b class="fa fa-caret-right"></b><i><a href="../老人信息.html">老人信息</a></i><b class="fa fa-caret-right"></b><i>新增老人</i></div>
            </div>
            <form method="post" enctype="multipart/form-data" class="form-inline">
            <div class="new-om-content">
                
                <div class="detail-content">
                    <h3>基本信息</h3>
                    <div class="col-xs-3"><img src="/layertwo-assets/img/02_03.png" id="img_view" name="photo"><button type="button" id="uploadBtn">上传照片</button></div>
                    <div style="display:none;"><input type="file" id="file" name="img"/></div>
                    <div class="col-xs-9">
                        <div class="col-xs-12">
                            <div><label><b>*</b>姓名</label><input type="text" name="senior_name"></div>
                            <div><label><b class="om-seds">*</b>院区</label><select name="department" id=""><option value="选择院区">选择院区</option><?foreach($tDIDatas as $tDIRow){?><option value="<?=$tDIRow['num']?>"><?=$tDIRow['introduce']?></option><?}?></select></div>
                            <div class="sed"><label><b>*</b>身体状况</label><select name="body_status"><?foreach($tBIDatas as $tBIRow){?><option value="<?=$tBIRow['num']?>"><?=$tBIRow['introduce']?></option><?}?></select></div>
                            <div><label><b>*</b>性别</label><select name="sex"><option value="1">男</option><option value="2">女</option><option value="0">未知</option></select></div>
                            <div id="longtext"><label><em>*</em>身份证号</label><input type="text" name="critcode"></div>
                            <div><label><em>*</em>年龄</label><input type="text" name="age"></div>
                            <div><label><em>*</em>出生年月</label><input type="text" name="birth_date" onclick="WdatePicker();"></div>

                          <div id="longtext"><label><em>*</em>户口所在地</label><input type="text" name="permanent_residence"></div>
                          <div><label>民族</label><select name="nation"><?foreach($tNIDatas as $tNIRow){?><option value="<?=$tNIRow['num']?>"><?=$tNIRow['introduce']?></option><?}?></select></div>
                          <div><label>宗教</label><select name="religion"><?foreach($tRIDatas as $tRIRow){?><option value="<?=$tRIRow['num']?>"><?=$tRIRow['introduce']?></option><?}?></select></div>

                          <div id="longtext"><label>原工作单位</label><input type="text" name="old_company"></div>
                          <div><label>婚姻情况</label><select name="married"><option value="1">未婚</option><option value="2">已婚</option><option value="3">离异</option><option value="4">丧偶</option><option value="5">未知</option></select></div>
                          <div><label>文化程度</label><select name="education_levels"><?foreach($tEIDatas as $tEIRow){?><option value="<?=$tEIRow['num']?>"><?=$tEIRow['introduce']?></option><?}?></select></div>

                          <div><label>家庭住址</label><input type="text" name="old_address"></div>

                          </div>
                    </div>
                </div>
                <h3>费用信息</h3>
                 <div class="col-xs-12 fee-content">

                    <div><label>医保</label><select name="medical_status"><option value="1">有</option><option value="2">无</option></select></div>
                    <div><label>医保卡号</label><input type="text" name="card_number"></div>
                    <div><label>基础费用</label><input type="text" name="basic_fee"></div>
                    <div><label>折扣</label><select name="charge_discount"><?foreach($tDisDatas as $tDisRow){?><option value="<?=$tDisRow['num']?>"><?=$tDisRow['introduce']?></option><?}?></select></div>
                    <div><label>付款类型</label><select name="payment"><?foreach($tPIDatas as $tPIRow){?><option value="<?=$tPIRow['num']?>"><?=$tPIRow['introduce']?></option><?}?></select></div>
                 </div>
                <h3 class="client-title">委托人信息</h3>
                    <div class="col-xs-12 client-content">
                        <div class="col-xs-2"><em>*</em><label>姓名</label><br><input type="text" name="wt_name"></div>
                        <div class="col-xs-2"><em>*</em><label>性别</label><br><select name="wt_sex"><option value="1">男</option><option value="2">女</option><option value="0">未知</option></select></div>
                        <div class="col-xs-2"><em>*</em><label>关系</label><br><input type="text" name="wt_relation"></div>
                        <div class="col-xs-2"><em>*</em><label>联系电话</label><input type="text" name="wt_phone"></div>
                        <div class="col-xs-2"><em>*</em><label>身份证号</label><br><input type="text" name="wt_critcode"></div>
                        <div class="col-xs-2"><em>*</em><label>家庭住址</label><br><input type="text" name="wt_address"></div>
                    </div>
                 <h3>家属信息(至少填写一位家属)<button id="addQinshu" type="button" onclick="addJiashu();">添加</button></h3>
                    <table class='familyadd-content'>
                 <thead>
                  <tr>
                    <th><label>姓名</label></th>
                    <th><label>性别</label></th>
                    <th><label>关系</label></th>
                    <th><label>联系电话</label></th>
                    <th><label>身份证号</label></th>
                    <th><label>家庭住址</label></th>
                    <th><label>操作</label></th>
                  </tr>
              </thead>
             <tbody class="qinshu">
                  <tr>
                    <td><input type="text" name="js_name[]"></td>
                    <td><select name="js_sex[]"><option value="1">男</option><option value="2">女</option></select></td>
                    <td><input type="text" name="js_relation[]"></td>
                    <td><input type="text" name="js_phone[]"></td>
                    <td><input type="text" name="js_critcode[]"></td>
                    <td><input type="text" name="js_address[]"></td>
                    <td><button class="delBtn" type="button" onclick="$(this).parent().parent().remove();">删除</button></td>
                  </tr>
             </tbody>
          </table>

                    <h3>老人习惯</h3>
                    <div class="habit-content">
                        <div class="col-xs-12"><div class="col-xs-3">饮食习惯</div><div class="col-xs-9"><input type="text" name="diet"></div></div>
                        <div class="col-xs-12"><div class="col-xs-3">生活习惯</div><div class="col-xs-9"><input type="text" name="life"></div></div>
                        <div class="col-xs-12"><div class="col-xs-3">睡眠习惯</div><div class="col-xs-9"><input type="text" name="sleep"></div></div>
                    </div>
                    <h3>其他信息</h3>
                    <div class="habit-content else-content">
                        <div class="col-xs-12"><div class="col-xs-3"><em>*</em>病史/过敏史</div><div class="col-xs-9"><input type="text" name="allergies"></div></div>
                        <div class="col-xs-12"><div class="col-xs-3"><em>*</em>用药医嘱</div><div class="col-xs-9"><input type="text"  name="medical_orders"></div></div>
                        <div class="col-xs-12"><div class="col-xs-3">自测体检</div><div class="col-xs-9"><input type="text" name="physical_examination"></div></div>
                        <div class="col-xs-12"><div class="col-xs-3">诊断诊断</div><div class="col-xs-9"><input type="text" name="discharge_diagnosis"></div></div>
                        <div class="col-xs-12"><div class="col-xs-3">管路护理</div><div class="col-xs-9"><input type="text" name="temper_hobby"></div></div>
                    </div>
                    <h3>扫描件信息</h3>
                    <div class="col-xs-12 scan-content">
                        <div class="scan-img"><img src="/layertwo-assets/img/scan_03.png"><span onclick="del(0)"></span></div>
                        <div class="scan-field"><input type="file" id="file_img" name="file_img[]" multiple="multiple"/></div>
                    </div>
            </div>
            <div class="footer"><div><button id="save" type="button">保存</button><button type="reset">取消</button></div></div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript" src="/senior_assets/js/jquery.min.js"></script>
<script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="/plugins/SweetAlert/sweetalert.min.js"></script><!--alert插件-->
<script src="/js/jquery.form.js"></script><!--form表单插件-->
<script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
<script type="text/javascript">
var reader = new FileReader();
var upload = function(){};
var a = 1;
upload.prototype.input_file_click = function(filename){
    var fileObj = $('input[name="'+filename+'"]'); 
    fileObj.bind('change',function(){
        var file = document.getElementById(filename.replace("[]","")).files;  
        for(var i in file){
            a++;
            //将文件以Data URL形式读入页面  
            var reader = new FileReader();  
            reader.readAsDataURL(file[i]);  
            reader.onload=function(e){  
                $('#'+filename.replace("[]","")).parent().before('<div class="scan-img"><img data-original="'+e.target.result+'" data="img_min" class="img_min" src="' + e.target.result +'" alt="" style="float:left;margin-right:10px;margin-bottom:20px;"/><span onclick="del('+a+')" id="d'+a+'"></span></div>');  
            };
        }
        fileObj.unbind('change');
    });
    fileObj.click();
}
var up  = new upload();
$(function(){
    $('.scan-field').on('click',function(){
        up.input_file_click('file_img[]');
    });
    $('.img_min').each(function(){
        $(this).on('click',function(){
           $(this).toggleClass('img_min'); 
           $(this).toggleClass('img_max'); 
        });
    });
    $('#uploadBtn').click(function(){
    $('#file').click();
    });
    var result = document.getElementById('img_view');
    var input = document.getElementById('file');
    if(typeof FileReader==='undefined'){
        result.innerHTML = '抱歉，你的浏览器不支持 FileReader';
        input.setAttribute('disabled','disabled');
    }else{
        input.addEventListener('change',readFile,false);
    }
    function readFile(){
        var file = this.files[0];
        if(!/image\/\w+/.test(file.type)){
            alert('文件必须为图片');
            return false;
        }
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            $('img[name="photo"]').attr('src',this.result);
        }
    }
});
function del(i){
    $("#d"+i).parent().remove();
}
</script>
<script type="text/javascript">
$(function() {
    $(".fakeloader").fakeLoader({
        timeToHide:500,
        bgColor:"#222",
        spinner:"spinner7"
    });

    $('#main-navigation-menu > li').removeClass('active');
    url = window.location.pathname;

    $('#main-navigation-menu > li').each(function(i){
        var ul_children = $(this).children('ul').html();
        if(ul_children != undefined){
            ul_children = $(this).children('ul')
            $(ul_children).children('li').each(function(){
                menu_url = $(this).children('a').attr('href');
            });
        }else{
            menu_url = $(this).children('a').attr('href');
            patt1 = new RegExp(menu_url);
            //alert(url);
            if(patt1.test(url)){
                $(this).addClass('active');
            }
        }
    })
})
function cg_alert_add(obj,list_url,add_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续添加',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = add_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_alert_edit(obj,list_url,edit_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续修改',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = edit_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_confirm_del(del_url,jump_url){
    swal({
            title: '您确定要删除吗？',
            text:'删除之后不能恢复',
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText:'确定',
            closeOnConfirm: false,
            cancelButtonText:'取消'
        },
        function(isConfirm){
            if(isConfirm){
                window.obj = '';
                $.ajax({
                    url: del_url,
                    dataType: "json",
                    async:false,
                    success: function (obj) {
                        window.obj = obj;
                    }
                });

                if(window.obj.status == 1){
                    swal({title:"删除成功!", type:"success"},function(){
                        location.href = jump_url;
                    });
                }else{
                    swal({title:window.obj.msg, type:"error"});
                }
            }
        });
}
function addJiashu(){
    $('.qinshu').append('<tr><td><input type="text" name="js_name[]"></td><td><select name="js_sex[]"><option value="1">男</option><option value="2">女</option><option value="3">未知</option></select></td><td><input type="text" name="js_relation[]"></td><td><input type="text" name="js_phone[]"></td><td><input type="text" name="js_critcode[]"></td><td><input type="text" name="js_address[]"></td><td><button type="button" class="delBtn" onclick="$(this).parent().parent().remove();">删除</button></td></tr>');
}
</script>
<script type="text/javascript">
$(function(){
//提交
    var options={
        beforeSubmit : showRequest,    // 提交前的回调函数
        success : showResponse,    // 提交后的回调函数
        dataType : "json",    // html（默认）、xml、script、json接受服务器端返回的类型
        timeout : 3000    // 限制请求的时间，当请求大于3秒后，跳出请求
    }
    function showRequest(formData, jqForm, options){
        return true;
    }
    function showResponse(responseText,statusText){
        cg_alert_add(responseText,'/admin_senior','/admin_senior/add');
    }
    $('#save').click(function(){
       $('form').ajaxSubmit(options); 
    });
});
</script>
